package yzy.ecps.dao.impl;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import yzy.ecps.dao.ShipAddrDao;
import yzy.ecps.model.BtcShipAddr;

@Repository
public class ShipAddrDaoImpl extends SqlSessionDaoSupport implements ShipAddrDao {
	
	String ns = "btc_ship_addr.";
	
	public void addShipAddr(BtcShipAddr addr) {
		getSqlSession().insert(ns+"insert", addr);
	}

	public void updateShipAddr(BtcShipAddr addr) {
		getSqlSession().update(ns+"updateByPrimaryKeySelective", addr);
	}

	public void cancelDefaultAddr(Long userId) {
		getSqlSession().update(ns+"cancelDefaultAddr", userId);
	}

	public List<BtcShipAddr> findByUserId(Long userId) {
		return getSqlSession().selectList(ns+"findByUserId", userId);
	}

	public void deleteShipAddr(Long addrId) {
		getSqlSession().delete(ns+"deleteByPrimaryKey", addrId);
	}

	public BtcShipAddr findAddrById(Long addrId) {
		return getSqlSession().selectOne(ns+"selectByPrimaryKey", addrId);
	}

}
